<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="org.wso2.carbon.registry.common.utils.RegistryUtil" %>
<%@ page import="org.wso2.carbon.registry.custom.skb.ui.utils.GetKBUtil" %>
<%@ page import="org.wso2.carbon.registry.common.ui.UIException" %>
<%@ page import="org.wso2.carbon.registry.custom.skb.ui.beans.KBItem" %>

<html>
    <head>
        <title>Support Knowledge Base</title>
        <link rel="stylesheet" type="text/css" href="css/style.css">
        <link rel="stylesheet" type="text/css" href="css/positioning.css">


        <%@ include file="js/InfoHandler.js" %>


        <jsp:include page="../dialog/dialog_header.jsp"/>
        <jsp:include page="../dialog/display_messages.jsp"/>

        <link href="../admin/css/global.css" rel="stylesheet" type="text/css" media="all"/>

        <link href="../admin/jsp/registry_styles_ajaxprocessor.jsp" rel="stylesheet" type="text/css" media="all"/>

        <link href="../admin/css/main.css" rel="stylesheet" type="text/css" media="all"/>
        <link href="../dialog/css/jqueryui/jqueryui-themeroller.css" rel="stylesheet" type="text/css" media="all"/>
        <link href="../dialog/css/dialog.css" rel="stylesheet" type="text/css" media="all"/>
        <link rel="icon" href="../admin/images/favicon.ico" type="image/x-icon"/>
        <link rel="shortcut icon" href="../admin/images/favicon.ico" type="image/x-icon"/>

        <script type="text/javascript" src="../admin/js/jquery.js"></script>
        <script type="text/javascript" src="../admin/js/jquery.form.js"></script>
        <script type="text/javascript" src="../dialog/js/jqueryui/jquery-ui.min.js"></script>
        <script type="text/javascript" src="../admin/js/main.js"></script>
        <script type="text/javascript" src="../admin/js/WSRequest.js"></script>
        <script type="text/javascript" src="../admin/js/cookies.js"></script>


        <script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
        <script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
        <script type="text/javascript" src="../ajax/js/prototype.js"></script>
        <script type="text/javascript" src="../resources/js/resource_util.js"></script>
        <link rel="stylesheet" type="text/css" href="../resources/css/registry.css"/>
        <link rel="stylesheet" type="text/css" href="../resources/css/registry.css"/>

        <style type="text/css">
            .yui-skin-sam h3 {
                font-size: 10px !important;
            }

            .yui-toolbar-container .yui-toolbar-titlebar h2 a {
                font-size: 11px !important;
            }
        </style>

    <body>

        <script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
        <script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
        <script type="text/javascript" src="../ajax/js/prototype.js"></script>


        <script type="text/javascript" src='../yui/build/utilities/utilities.js'></script><script type="text/javascript" src='../yui/build/yahoo/yahoo-min.js'></script><script type="text/javascript" src='../yui/build/json/json-min.js'></script><script type="text/javascript"> var org_wso2_carbon_registry_resource_ui_tmpPairs = '{"dialog.cancel":"Cancel","dialog.ok":"OK","unable.to.upload":"Unable to upload the resource from the given URL.","picked.path.empty":"The required field Picked Path has not been filled in.","insert.image":"Insert Image","font.name.and.size":"Font Name and Size","good":"Good","select.user.for.permission":"Please select a User for Permission","italic":"Italic CTRL + SHIFT + I","password":"Password","user.authenticated.successfully":"User authenticated successfully.<br/>Signing in to the WSO2 Registry ...","error.occured":"Error Occurred!","unauthorized.to.add.links":"You do not have sufficient authorizations to create a link.","html.link":"HTML Link CTRL + SHIFT + L","failed.to.create.remote.link":"Failed to create Remote Link.","bold":"Bold CTRL + SHIFT + B","resource.exits":"A resource already exists at the given path:","permanently":"permanently?","destination.path":"Destination Path","verify.password":"Please verify your password again.","description":"Description","role.name":"Role Name","resource.does.not.exit":"Resource does not exist at path:","are.you.sure.you.want.to.delete":"Are you sure you want to delete","successfully.created.symbolic.link":"Successfully created Symbolic Link.","copied":"copied","could.not.get.custom.ui.media.type.information":"Could not get custom ui media types information from the server.","collection.exits":"A collection already exists at the given path:","session.timed.out":"Session timed out. Please login again.","successfully.created.remote.link":"Successfully created Remote Link.","failed.to.update":"Failed to update the resource.","registry.key.cannot.be.null.or.empty":"Registry Key input field ID cannot be null or empty","unsupported.media.type.to.upload":"Unsupported media type to upload","save.description":"Save Description","could.not.get.collection.media.type.information":"Could not get collection media types information from the server.","url":"URL","create.ordered.list":"Create an Ordered List","check.point.created":"Check point created successfully","the.given.name":"The given Name","the.given.description":"The given Description","user.name":"User name","registry.not.responding":"ERROR: Registry is not responding.","unsupported.media.type.to.display":"Unsupported media type to display as text","permission.applied.successfully":"Permission applied successfully","failed.to.delete":"Failed to delete","unable.to.move.resource.to":"Unable to move resource to","successfully.uploaded":"Successfully uploaded the resource from the given URL.","collection":"collection","display.name":"Display name","font.style":"Font Style","file.path.not.filled":"The required field File Path has not been filled in.","failed.to.add.collection":"Failed to add the collection.","renamed":"renamed","not.a.valid.path":"is not a valid path.","unable.create.symlink.to.root":"Unable to create a Symbolic Link to the root collection.","successfully.added.collection":"Successfully added new collection.","underline":"Underline CTRL + SHIFT + U","name":"Name","path":"Path","file.path":"File Path","evening":"evening","select.action.for.permission":"Please select an Action for Permission","lists":"Lists","media.type":"Media type","successfully.added.text.content":"Successfully added Text content.","cannot.contain.more.than1":"cannot contain more than 256 characters.","cannot.contain.more.than2":"cannot contain more than 1000 characters.","unsupported.media.type.to.edit":"Unsupported media type to edit as text","error":"ERROR","edit.description":"Edit Description","afternoon":"afternoon","could.not.get.media.type.information":"Could not get media types information from the server.","resource":"resource","morning":"morning","please.make.sure.passwords.are.matching":"Please make sure Password and Confirm Password fields are matching.","font.color":"Font Color","moved":"moved","select.a.value":"Select A Value","failed.to.add.text.content":"Failed to add Text content.","resource.tree":"Resource Tree","unable.to.copy.resource.to":"Unable to copy resource to","form.processing.failed":"Form processing failed","insert.item":"Insert Item","successfully":"Successfully","create.unordered.list":"Create an Unordered List","content.url":"Content URL","resource.tree.loading":"Resource tree loading please wait ..","background.color":"Background Color","failed.to.create.symbolic.link":"Failed to create Symbolic Link."}'; var org_wso2_carbon_registry_resource_ui_jsi18n = YAHOO.lang.JSON.parse(org_wso2_carbon_registry_resource_ui_tmpPairs);</script>
        <script type="text/javascript" src="js/resource_util.js"></script>
        <!-- including the JS for properties, since JS can't be loaded via async calls. -->


        <script type="text/javascript" src='../yui/build/utilities/utilities.js'></script><script type="text/javascript" src='../yui/build/yahoo/yahoo-min.js'></script><script type="text/javascript" src='../yui/build/json/json-min.js'></script><script type="text/javascript"> var org_wso2_carbon_registry_properties_ui_tmpPairs = '{"dialog.cancel":"Cancel","dialog.ok":"OK","property.value":"Property Value","are.you.sure.you.want.to.delete":"Are you sure you want to delete","permanently":"permanently?","property.value.cannot.contain.only.white.spaces":"Property value cannot contain only white spaces","session.timed.out":"Session timed out. Please login again.","property.name":"Property Name","property.name.cannot.contain.only.white.spaces":"Property name cannot contain only white spaces","duplicate.entry.please.choose.another.name":"Duplicate entry. Please choose a different name.","property.operation.in.progress":"A property operation is currently in progress. Please try again later."}'; var org_wso2_carbon_registry_properties_ui_jsi18n = YAHOO.lang.JSON.parse(org_wso2_carbon_registry_properties_ui_tmpPairs);</script>
        <script type="text/javascript" src="../properties/js/properties.js"></script>
    </head>


    <%
        String cPath = request.getParameter("path");
        KBItem kbItem;
        try {
            kbItem = GetKBUtil.getKBItem(cPath, config, session);
        } catch (UIException e) {
    %>Error occured while retrieving kb item details<%
            return;
        }

    %>


    <form id="skbEditForm" action="skb_edit_handler_ajaxprocessor.jsp" method="post">
        <input type="hidden" name="path" value="<%=cPath%>"/>
            <table id="main-table" border="0" cellspacing="0">
                <tr>
                    <td id="header" colspan="3">
                        <div id="header-div">
                            <div class="right-logo">Support Knowledge Base</div>
                            <div >
                                <br>
                                <a href="../admin/index.jsp"><img style="border: 0px solid ; width: 93px; height: 38px;" alt="wso2-logo" title="WSO2 Inc." src="images/wso2-logo.gif" align="left"></a>
                                <h3>&nbsp;&nbsp;&nbsp;<a href="skb_home_ajaxprocessor.jsp">Home</a>
                                    | <a href="javascript:void(0);" onclick="skb_api.loadPage('add')">Add</a>
                                    | <a href="javascript:void(0);" onclick="skb_api.loadPage('browse')">Browse</a><br>
                                </h3>
                            </div>
                            <div class="kheader-links">
                                <div class="kright-links">
                                    <ul>

                                        <li class="right">
                                            <a href="../admin/login.jsp">Sign-in</a>
                                        </li>

                                        <li class="middle">|</li>
                                        <li class="middle">
                                            <form action="../search/search.jsp" method="get" style="display: inline;" name="searchForm">
                                                <table class="styledLeft" cellspacing="0" cellpadding="0" border="0">
                                                    <tbody>
                                                        <tr>
                                                            <td>
                                                                <input id="region" type="hidden" value="region3" name="region"/>
                                                                <input id="item" type="hidden" value="registry_search_menu" name="item"/>
                                                                <input id="criteria" class="input-text" type="text" name="criteria"/>
                                                                <select id="searchType" style="display: none;" name="searchType"> </select>
                                                            </td>
                                                            <td class="buttonRow">
                                                                <input class="button" type="button" value="Search" onclick="document.forms['searchForm'].submit();"/>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </form>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td id="menu-panel" valign="top" style="width: 230px;">
                        <div id="leftTree" style="width: 230px;">
                            <%@ include file="treeViewer.jsp" %>
                        </div>
                    </td>
                    <td id="middle-content" style ="height: 100%">
                        <div id="middleDiv" >
                            <table style="width: 80% " class="styledLeft" >
                                <thead><tr><th colspan="2">Knowledge Base Item</th></tr></thead>
                                <tbody>
                                    <tr>
                                        <td>Name</td>
                                        <td><textarea  rows="3" cols="15" name="problemName" id="problemName" class="normal-textarea" style="margin-left: 2px; margin-right: 2px; width: 541px; "><%=kbItem.getProblemName()%></textarea></td>
                                    </tr>

                                    <tr>
                                        <td>Issue Link: </td>
                                        <td><input type="text" name="link" style="width: 541px; " value="<%=kbItem.getLink()%>"/></td>
                                    </tr>

                                    <tr>
                                        <td>Description</td>
                                        <td><textarea  rows="4" cols="15" name="description" id="description" class="normal-textarea" style="margin-top: 2px; margin-bottom: 2px; height: 68px; margin-left: 2px; margin-right: 2px; width: 541px; "><%=kbItem.getDescription()%></textarea></td>
                                    </tr>

                                    <tr>
                                        <td>Questions</td>
                                        <td>
                                            <table>
                                                <%
                                                  String qn = kbItem.getQuestion();
                                                  String qns[] = qn.split("###,");
                                                  for(int i=0;i<qns.length;i++){
                                                      String name1 = qns[i];
                                                      name1 = name1.replace("###","");
                                                %>
                                                <tr><textarea  name="question<%=i%>" id="question<%=i%>" class="normal-textarea" style="margin-top: 2px; margin-bottom: 2px; height: 53px; margin-left: 2px; margin-right: 2px; width: 424px; "><%=name1%></textarea></tr>
                                                <%
                                                   }
                                                %>
                            </table>
                            </td>
                            </tr>
                            <tr>
                                <td>Answers</td>
                                <td>
                                    <table>
                                        <%
                                          String an = kbItem.getAnswer();
                                          String ans[] = an.split("###,");
                                          for(int i=0;i<ans.length;i++){
                                              String name2 = ans[i];
                                              name2 = name2.replace("###","");
                                        %>
                                        <tr><textarea  name="answer<%=i%>" id="answer<%=i%>" class="normal-textarea" style="margin-top: 2px; margin-bottom: 2px; height: 53px; margin-left: 2px; margin-right: 2px; width: 424px; "><%=name2%></textarea></tr>
                                        <%
                                           }
                                        %>
                            </table>
                            </td>
                            </tr>
                            <tr>
                                <td>Solution</td>
                                <td>
                                    <table>
                                        <%
                          String sol = kbItem.getSolution();
                          String solns[] = sol.split("###,");
                          for(int i=0;i<solns.length;i++){
                              String name3 = solns[i];
                              name3 = name3.replace("###","");
                                        %>
                                        <tr><textarea  name="solution<%=i%>" id="solution<%=i%>" class="normal-textarea" style="margin-top: 2px; margin-bottom: 2px; height: 53px; margin-left: 2px; margin-right: 2px; width: 428px; "><%=name3%></textarea></tr>
                                        <%
                                           }
                                        %>
                            </table>
                            </td>
                            </tr>
                            <tr>
                                <td>Product</td>
                                <td>
                                    <table>
                                        <%
                                          String product = kbItem.getProduct();
                                          String productR = kbItem.getProductRelease();
                                        %>
                                        <tr><td><input type="text" name="product" id="product" value="<%=product%>"/></td><td><input type="text" name="productRelease" id="productRelease" value="<%=productR%>"/></td></tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td>Environment</td>
                                <td>
                                    <table>
                                        <%
                                          String jdkP= kbItem.getJDKPlatform();
                                          String cP = kbItem.getCarbonPlatform();
                                        %>
                                        <tr><td>JDK Platform</td><td><input type="text" name="carbonPlatform" id="carbonPlatform"  value="<%=cP%>"/></td></tr>
                                        <tr><td>Carbon Platform</td><td><input type="text" name="jdkPlatform" id="jdkPlatform"   value="<%=jdkP%>"/></td></tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td>Tags</td>
                                <td>
                                    <%
                                      String keywords= kbItem.getKeyWord();
                                    %>
                                    <input type="text" name="keyWord"  value="<%=keywords%>" style="width: 541px; "/>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" class="buttonRow"><input class="button" type="submit" value="Save"/></td>
                            </tr>
                                <br/>
                                <br/>
                                <br/>
                                </tbody>
                            </table>

                        </div>
                    </td>

                </tr>

                <tr>
                    <td colspan="2">
                        <div id="footer" >
                            <div class="footer-content">
                                <div class="copyright"> © 2008 - 2010 WSO2 Inc. All Rights Reserved. </div>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
    </form>
</body>
</html>












<!--table width="50%">
    <thead>
        <tr>
            <th colspan="2"><strong>Edit KBItem</strong></th>
        </tr>
    </thead>
    <tbody>
        <tr><td class="leftCol-med">Problem Name <span class="required">*</span></td>
            <td><input type="text" name="name" value="//=kbitem.getProblemName()"/></td>
        </tr>
        <tr>

        <tr>
            <td colspan="2" class="buttonRow"><input class="button" type="submit" value="Save"/></td>
        </tr>
    </tbody>
</table-->



